package com.example.homework_3;

import android.content.res.Configuration;
import android.os.Bundle;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;

public class ConfigurationTest extends AppCompatActivity {

    TextView tvShowOri, tvShowNav, tvShowMnc, tvShowTouch;
    Configuration configuration;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_configuration_test);

        tvShowOri = findViewById(R.id.tvShowOri);
        tvShowNav = findViewById(R.id.tvShowNav);
        tvShowMnc = findViewById(R.id.tvShowMnc);
        tvShowTouch = findViewById(R.id.tvShowTouch);

        configuration = getResources().getConfiguration();

        if (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
            tvShowOri.setText("横向屏幕");
        }
        else {
            tvShowOri.setText("竖向屏幕");
        }

        if (configuration.orientation == Configuration.NAVIGATION_NONAV) {
            tvShowNav.setText("没有方向控制");
        }
        else if (configuration.orientation == Configuration.NAVIGATION_WHEEL) {
            tvShowNav.setText("滚轮控制方向");
        }
        else if (configuration.orientation == Configuration.NAVIGATION_DPAD) {
            tvShowNav.setText("方向键控制方向");
        }
        else {
            tvShowNav.setText("轨迹球控制方向");
        }

        tvShowMnc.setText("" + configuration.mnc);

        if (configuration.touchscreen == Configuration.TOUCHSCREEN_NOTOUCH) {
            tvShowTouch.setText("无触摸屏");
        }
        else if (configuration.touchscreen == Configuration.TOUCHSCREEN_STYLUS) {
            tvShowTouch.setText("触摸笔式触摸屏");
        }
        else {
            tvShowTouch.setText("接受手指的触摸屏");
        }
    }
}